8046c8983804ea5b927bbbc1d6855cd6987d720c,hemesh/src/wblut/geom/WB_GeometryOp.java,WB_GeometryOp,getClosestPoint3D,#WB_Coordinate#WB_Polygon#,3314
Before Change
int[] T;
for (int i = 0; i < n; i++) {
T = tris[i];
tmp = getClosestPointToTriangle3D(p, poly.getPoint(T[0]),
poly.getPoint(T[1]), poly.getPoint(T[2]));
final double d2 = getSqDistance3D(tmp, p);
if (d2 < dmax2) {
closest = tmp;
dmax2 = d2;
}
}
return closest;
After Change
int[] T;
for (int i = 0; i < n; i++) {
T = tris[i];
WB_Coordinate q = p;
if (n > 1) {
q = projectOnPlane(p,
new WB_Plane(poly.getPoint(T[0]), poly.getPoint(T[1]),
poly.getPoint(T[2])));
}
tmp = getClosestPointToTriangle3D(q, poly.getPoint(T[0]),
poly.getPoint(T[1]), poly.getPoint(T[2]));
final double d2 = getSqDistance3D(tmp, q);
if (d2 < dmin2) {
closest = tmp;
dmin2 = d2;
}
}
return closest;